KSoap veri çekme?
09.08.2016 - 09:13
XML bu şekilde. Ben android studio da burdakilerden birini textview e yazdırmak istiyorum ama null geliyor.
Kodları:
package com.example.asus34.akinsoftentegrasyon;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.lang.reflect.Array;
public class MainActivity extends AppCompatActivity {
private final String NAMESPACE = "http://192.168.56.1/";
private final String URL = "http://192.168.56.1/WebServis/AkinsoftRaporlar.asmx";
private final String SOAP_ACTION = "192.168.1.4/CariHareketGetir";
private final String METHOD_NAME = "CariHareketGetir";
private String TAG = "PGGURU";
private static String fahren;
Button b;
TextView tv;
EditText et1;
EditText et2;
ListView lv;
int s1;
String CariKodu;
Array myObjectArray;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Celcius Edit Control
et1 = (EditText) findViewById(R.id.editText1);
et2 = (EditText) findViewById(R.id.editText2);
//Fahrenheit Text control
tv = (TextView) findViewById(R.id.tv_result);
//Button to trigger web service invocation
b = (Button) findViewById(R.id.button1);
lv = (ListView) findViewById(R.id.listView);
//Button Click Listener
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Check if Celcius text control is not empty
//Create instance for AsyncCallWS
AsyncCallWS task = new AsyncCallWS();
//Call execute
task.execute();
}
});
}
private class AsyncCallWS extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
Log.i(TAG, "doInBackground");
CariHareket();
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.i(TAG, "onPostExecute");
tv.setText("Sonuc:" + fahren);
}
@Override
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
tv.setText("Hesaplanıyor...");
}
@Override
protected void onProgressUpdate(Void... values) {
Log.i(TAG, "onProgressUpdate");
}
}
private class MetotCalistir extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
Log.i(TAG, "doInBackground");
CariHareket();
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.i(TAG, "onPostExecute");
}
@Override
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
tv.setText("Hesaplanıyor...");
}
@Override
protected void onProgressUpdate(Void... values) {
Log.i(TAG, "onProgressUpdate");
}
}
public void CariHareket()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//Property which holds input parameters
PropertyInfo Cari1 = new PropertyInfo();
//Set Name
Cari1.setName("Carikodu");
//Set Value
Cari1.setValue(CariKodu);
//Set dataType
Cari1.setType(String.class);
//Add the property to request object
request.addProperty(Cari1);
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
//Set output SOAP object
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//Invole web service
androidHttpTransport.call(SOAP_ACTION, envelope);
//Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
//Assign it to fahren static variable
fahren = response.toString();
tv.setText(response.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
216
Görüntülenme
0 Beğeni